import { defineConfig } from "vite";
import { join, resolve } from "path";
import vue from "@vitejs/plugin-vue";
import ReactivityTransform from "@vue-macros/reactivity-transform/vite";
import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
import Components from "unplugin-vue-components/vite";
import { VantResolver } from "unplugin-vue-components/resolvers";

export default defineConfig({
  plugins: [
    vue(),
    // 响应式语法糖
    ReactivityTransform(),
    createSvgIconsPlugin({
      // 指定要缓存的图标文件夹
      iconDirs: [resolve(process.cwd(), "src/icons")],
      // 指定symbolId格式
      symbolId: "icon-[dir]-[name]",
    }),
    // 按需引入Vant组件库
    Components({
      resolvers: [VantResolver()],
    }),
  ],
  resolve: {
    // 路径别名
    alias: {
      "@": join(__dirname, "src"),
    },
  },
  // 开启IP域名访问
  server: {
    host: "0.0.0.0",
    port: 8080,
    open: true,
  },
});
